home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2003 September / PC Answers September 2003.iso / Software / freeware / pixeltoolbox / Setup.exe / Main / PixelToolbox.exe / PixelToolbox.dxr / Scripts_71_canvas script - 4bit.ls < prev    next >
Encoding:
Text File  |  2002-06-08  |  17.7 KB  |  452 lines

  1. property pSprite, pUndoTrigger
  2. global gProject, gSize, gCast, gVariable, gFirstColor, gSecondColor, g4bitValues, gPencilSize, gPencilShape, gEraserSize, gEraserShape, gBrushSize, gBrushShape, gAirbrushSize, gAirbrushShape, gGradientDirection, gClonerShape, gClonerSize, gClonerFlag, gClonerHDist, gClonerVDist, myCurrentImage, pPixelActorListX, pPixelActorListY, pSpreadListX, pSpreadListY, currentCursor, gCurrentColor, gShapeType, gRectStyle, gOvalStyle, gRoundRectStyle, gWvBgColor, gWvBgShadow, gWvVcolor, gWvVShadow, gWvHcolor, gWvHShadow, gMarqueeRect
  3.  
  4. on beginSprite me
  5.   pSprite = sprite(me.spriteNum)
  6.   pUndoTrigger = 0
  7. end
  8.  
  9. on mouseWithin me
  10.   if sprite(64).pState = 1 then
  11.     if gPencilSize = 1 then
  12.       nothing()
  13.     else
  14.       sprite(8).rect = rect(the mouseH - (gPencilSize * gVariable / 2), the mouseV - (gPencilSize * gVariable / 2), the mouseH + (gPencilSize * gVariable / 2), the mouseV + (gPencilSize * gVariable / 2))
  15.     end if
  16.   else
  17.     if sprite(73).pState = 1 then
  18.       sprite(8).rect = rect(the mouseH - (gBrushSize * gVariable / 2), the mouseV - (gBrushSize * gVariable / 2), the mouseH + (gBrushSize * gVariable / 2), the mouseV + (gBrushSize * gVariable / 2))
  19.     else
  20.       if sprite(84).pState = 1 then
  21.         if gEraserSize = 1 then
  22.           nothing()
  23.         else
  24.           sprite(8).rect = rect(the mouseH - (gEraserSize * gVariable / 2), the mouseV - (gEraserSize * gVariable / 2), the mouseH + (gEraserSize * gVariable / 2), the mouseV + (gEraserSize * gVariable / 2))
  25.         end if
  26.       else
  27.         if sprite(96).pState = 1 then
  28.           sprite(8).rect = rect(the mouseH - (gAirbrushSize * gVariable / 2), the mouseV - (gAirbrushSize * gVariable / 2), the mouseH + (gAirbrushSize * gVariable / 2), the mouseV + (gAirbrushSize * gVariable / 2))
  29.         else
  30.           if sprite(104).pState = 1 then
  31.             if gClonerSize = 1 then
  32.               if gClonerFlag = 0 then
  33.                 nothing()
  34.               else
  35.                 sprite(9).loc = point(((the mouseH - sprite(1).left) * 2 / gVariable / 2 * gVariable) + sprite(1).left + (gVariable / 2) + (gClonerHDist * gVariable), ((the mouseV - sprite(1).top) * 2 / gVariable / 2 * gVariable) + sprite(1).top + (gVariable / 2) + (gClonerVDist * gVariable))
  36.               end if
  37.             else
  38.               if gClonerFlag = 0 then
  39.                 sprite(8).rect = rect(the mouseH - (gClonerSize * gVariable / 2), the mouseV - (gClonerSize * gVariable / 2), the mouseH + (gClonerSize * gVariable / 2), the mouseV + (gClonerSize * gVariable / 2))
  40.               else
  41.                 sprite(8).rect = rect(the mouseH - (gClonerSize * gVariable / 2), the mouseV - (gClonerSize * gVariable / 2), the mouseH + (gClonerSize * gVariable / 2), the mouseV + (gClonerSize * gVariable / 2))
  42.                 sprite(9).loc = point(((the mouseH - sprite(1).left) * 2 / gVariable / 2 * gVariable) + sprite(1).left + (gVariable / 2) + (gClonerHDist * gVariable), ((the mouseV - sprite(1).top) * 2 / gVariable / 2 * gVariable) + sprite(1).top + (gVariable / 2) + (gClonerVDist * gVariable))
  43.               end if
  44.             end if
  45.           else
  46.             if sprite(146).pState = 1 then
  47.               if (gMarqueeRect <> rect(0, 0, 0, 0)) and inside(point(the mouseH, the mouseV), gMarqueeRect) then
  48.                 pSprite.cursor = [412, 413]
  49.               else
  50.                 pSprite.cursor = 271
  51.               end if
  52.             end if
  53.           end if
  54.         end if
  55.       end if
  56.     end if
  57.   end if
  58.   put (the mouseH - sprite(1).left) * 2 / gVariable / 2 into field "location status X"
  59.   put (the mouseV - sprite(1).top) * 2 / gVariable / 2 into field "location status Y"
  60. end
  61.  
  62. on mouseEnter me
  63.   if sprite(64).pState = 1 then
  64.     pSprite.cursor = 256
  65.     member(391).shapeType = gPencilShape
  66.   else
  67.     if sprite(73).pState = 1 then
  68.       pSprite.cursor = [350, 351]
  69.       member(391).shapeType = gBrushShape
  70.     else
  71.       if sprite(84).pState = 1 then
  72.         pSprite.cursor = [352, 353]
  73.         member(391).shapeType = gEraserShape
  74.       else
  75.         if sprite(96).pState = 1 then
  76.           pSprite.cursor = [354, 355]
  77.           member(391).shapeType = gAirbrushShape
  78.         else
  79.           if sprite(104).pState = 1 then
  80.             pSprite.cursor = [348, 349]
  81.             member(391).shapeType = gClonerShape
  82.           else
  83.             if sprite(116).pState = 1 then
  84.               pSprite.cursor = 271
  85.               gShapeType = #rect
  86.             else
  87.               if sprite(121).pState = 1 then
  88.                 pSprite.cursor = 271
  89.                 gShapeType = #oval
  90.               else
  91.                 if sprite(126).pState = 1 then
  92.                   pSprite.cursor = 271
  93.                   gShapeType = #roundRect
  94.                 else
  95.                   if sprite(131).pState = 1 then
  96.                     pSprite.cursor = 271
  97.                   else
  98.                     if sprite(138).pState = 1 then
  99.                       pSprite.cursor = 271
  100.                     else
  101.                       if sprite(142).pState = 1 then
  102.                         pSprite.cursor = 259
  103.                       else
  104.                         if sprite(143).pState = 1 then
  105.                           pSprite.cursor = [344, 345]
  106.                         else
  107.                           if sprite(144).pState = 1 then
  108.                             pSprite.cursor = [346, 347]
  109.                           else
  110.                             if sprite(146).pState = 1 then
  111.                               pSprite.cursor = 271
  112.                             else
  113.                               if sprite(147).pState = 1 then
  114.                                 pSprite.cursor = 1
  115.                               else
  116.                                 if sprite(240).pState = 1 then
  117.                                   pSprite.cursor = [432, 433]
  118.                                 else
  119.                                   if sprite(272).pState = 1 then
  120.                                     pSprite.cursor = [466, 467]
  121.                                     sendSprite(3, #hotspotOn)
  122.                                   end if
  123.                                 end if
  124.                               end if
  125.                             end if
  126.                           end if
  127.                         end if
  128.                       end if
  129.                     end if
  130.                   end if
  131.                 end if
  132.               end if
  133.             end if
  134.           end if
  135.         end if
  136.       end if
  137.     end if
  138.   end if
  139.   currentCursor = pSprite.cursor
  140. end
  141.  
  142. on mouseLeave me
  143.   pSprite.cursor = 0
  144.   put EMPTY into field "location status X"
  145.   put EMPTY into field "location status Y"
  146.   if (sprite(64).pState = 1) or (sprite(73).pState = 1) or (sprite(84).pState = 1) or (sprite(96).pState = 1) or (sprite(104).pState = 1) then
  147.     sprite(8).rect = rect(-60, -60, 0, 0)
  148.   end if
  149.   if gProject = "cursor" then
  150.     if sprite(272).pState = 1 then
  151.       sendSprite(3, #hotspotOff)
  152.     end if
  153.   end if
  154. end
  155.  
  156. on mouseDown
  157.   if pUndoTrigger = 0 then
  158.     if sprite(146).pState <> 1 then
  159.       pUndoTrigger = 1
  160.     end if
  161.   end if
  162.   if sprite(64).pState = 1 then
  163.     if gPencilSize = 1 then
  164.       tool1PxPencil()
  165.     else
  166.       toolPencil()
  167.     end if
  168.   else
  169.     if sprite(73).pState = 1 then
  170.       toolBrush()
  171.     else
  172.       if sprite(84).pState = 1 then
  173.         if gEraserSize = 1 then
  174.           tool1PxEraser()
  175.         else
  176.           toolEraser()
  177.         end if
  178.       else
  179.         if sprite(96).pState = 1 then
  180.           toolAirbrush()
  181.         else
  182.           if sprite(104).pState = 1 then
  183.             if gClonerSize = 1 then
  184.               tool1PxCloner()
  185.             else
  186.               toolCloner()
  187.             end if
  188.           else
  189.             if sprite(116).pState = 1 then
  190.               if gRectStyle = "outline" then
  191.                 toolOutlineShape()
  192.               else
  193.                 if gRectStyle = "filled" then
  194.                   toolFilledShape()
  195.                 else
  196.                   if gRectStyle = "solid" then
  197.                     toolSolidShape()
  198.                   end if
  199.                 end if
  200.               end if
  201.             else
  202.               if sprite(121).pState = 1 then
  203.                 if gOvalStyle = "outline" then
  204.                   toolOutlineShape()
  205.                 else
  206.                   if gOvalStyle = "filled" then
  207.                     toolFilledShape()
  208.                   else
  209.                     if gOvalStyle = "solid" then
  210.                       toolSolidShape()
  211.                     end if
  212.                   end if
  213.                 end if
  214.               else
  215.                 if sprite(126).pState = 1 then
  216.                   if gRoundRectStyle = "outline" then
  217.                     toolOutlineShape()
  218.                   else
  219.                     if gRoundRectStyle = "filled" then
  220.                       toolFilledShape()
  221.                     else
  222.                       if gRoundRectStyle = "solid" then
  223.                         toolSolidShape()
  224.                       end if
  225.                     end if
  226.                   end if
  227.                 else
  228.                   if sprite(131).pState = 1 then
  229.                     toolStraightLine()
  230.                   else
  231.                     if sprite(138).pState = 1 then
  232.                       if gGradientDirection = "H" then
  233.                         toolGradientH4()
  234.                       else
  235.                         if gGradientDirection = "V" then
  236.                           toolGradientV4()
  237.                         else
  238.                           if gGradientDirection = "rect" then
  239.                             toolGradientRect4()
  240.                           else
  241.                             if gGradientDirection = "oval" then
  242.                               toolGradientOval4()
  243.                             end if
  244.                           end if
  245.                         end if
  246.                       end if
  247.                     else
  248.                       if sprite(142).pState = 1 then
  249.                         toolFill()
  250.                       else
  251.                         if sprite(143).pState = 1 then
  252.                           toolCheckerFill()
  253.                         else
  254.                           if sprite(144).pState = 1 then
  255.                             toolChangeColor()
  256.                           else
  257.                             if sprite(146).pState = 1 then
  258.                               if (gMarqueeRect <> rect(0, 0, 0, 0)) and inside(point(the mouseH, the mouseV), gMarqueeRect) then
  259.                                 moveSelect()
  260.                               else
  261.                                 toolSelect()
  262.                               end if
  263.                             else
  264.                               if sprite(147).pState = 1 then
  265.                                 toolText()
  266.                               else
  267.                                 if sprite(240).pState = 1 then
  268.                                   toolWarp()
  269.                                 else
  270.                                   if sprite(272).pState = 1 then
  271.                                     toolHotspot()
  272.                                   end if
  273.                                 end if
  274.                               end if
  275.                             end if
  276.                           end if
  277.                         end if
  278.                       end if
  279.                     end if
  280.                   end if
  281.                 end if
  282.               end if
  283.             end if
  284.           end if
  285.         end if
  286.       end if
  287.     end if
  288.   end if
  289. end
  290.  
  291. on rightMouseDown
  292.   if sprite(146).pState = 1 then
  293.     nothing()
  294.   else
  295.     if sprite(104).pState = 1 then
  296.       pSprite.cursor = [359, 360]
  297.       gClonerFlag = 0
  298.       sprite(9).blend = 100
  299.       sprite(9).loc = point(((the mouseH - sprite(1).left) * 2 / gVariable / 2 * gVariable) + sprite(1).left + (gVariable / 2), ((the mouseV - sprite(1).top) * 2 / gVariable / 2 * gVariable) + sprite(1).top + (gVariable / 2))
  300.     else
  301.       pSprite.cursor = [361, 362]
  302.       gCurrentColor = member(gSize & "x" & gSize, gCast).image.getPixel((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2)
  303.       put gCurrentColor.red into field "red status"
  304.       put gCurrentColor.green into field "green status"
  305.       put gCurrentColor.blue into field "blue status"
  306.       put gCurrentColor.hexString() into field "hex status"
  307.       put getProp(g4bitValues, gCurrentColor.paletteIndex) into field "paletteIndex status"
  308.       if sprite(47).rect = rect(598, 13, 622, 37) then
  309.         gFirstColor = gCurrentColor
  310.         member("1st Color", gCast).image.fill(member("1st Color", gCast).rect, gFirstColor)
  311.       else
  312.         if sprite(47).rect = rect(598, 43, 622, 67) then
  313.           gSecondColor = gCurrentColor
  314.           member("2nd Color", gCast).image.fill(member("2nd Color", gCast).rect, gSecondColor)
  315.         else
  316.           if sprite(47).rect = rect(48, 518, 67, 537) then
  317.             gWvBgColor = gCurrentColor
  318.             member("weave - bg color", gCast).image.fill(member("weave - bg color", gCast).rect, gWvBgColor)
  319.           else
  320.             if sprite(47).rect = rect(68, 518, 87, 537) then
  321.               gWvBgShadow = gCurrentColor
  322.               member("weave - bg shadow", gCast).image.fill(member("weave - bg shadow", gCast).rect, gWvBgShadow)
  323.             else
  324.               if sprite(47).rect = rect(48, 543, 67, 562) then
  325.                 gWvVcolor = gCurrentColor
  326.                 member("weave - V color", gCast).image.fill(member("weave - V color", gCast).rect, gWvVcolor)
  327.               else
  328.                 if sprite(47).rect = rect(68, 543, 87, 562) then
  329.                   gWvVShadow = gCurrentColor
  330.                   member("weave - V shadow", gCast).image.fill(member("weave - V shadow", gCast).rect, gWvVShadow)
  331.                 else
  332.                   if sprite(47).rect = rect(48, 568, 67, 587) then
  333.                     gWvHcolor = gCurrentColor
  334.                     member("weave - H color", gCast).image.fill(member("weave - H color", gCast).rect, gWvHcolor)
  335.                   else
  336.                     if sprite(47).rect = rect(68, 568, 87, 587) then
  337.                       gWvHShadow = gCurrentColor
  338.                       member("weave - H shadow", gCast).image.fill(member("weave - H shadow", gCast).rect, gWvHShadow)
  339.                     else
  340.                       if sprite(47).rect = rect(593, 263, 617, 287) then
  341.                         member("4bit transparency color", gCast).image.fill(member("4bit transparency color", gCast).rect, gCurrentColor)
  342.                         sprite(1).bgColor = gCurrentColor
  343.                         sprite(20).bgColor = gCurrentColor
  344.                         sprite(261).bgColor = gCurrentColor
  345.                         sprite(262).bgColor = gCurrentColor
  346.                         sprite(263).bgColor = gCurrentColor
  347.                         sprite(264).bgColor = gCurrentColor
  348.                         sprite(47).rect = rect(598, 13, 622, 37)
  349.                       end if
  350.                     end if
  351.                   end if
  352.                 end if
  353.               end if
  354.             end if
  355.           end if
  356.         end if
  357.       end if
  358.       gCurrentColor = VOID
  359.     end if
  360.   end if
  361. end
  362.  
  363. on rightMouseUp
  364.   if sprite(146).pState = 1 then
  365.     nothing()
  366.   else
  367.     pSprite.cursor = currentCursor
  368.     put EMPTY into field "red status"
  369.     put EMPTY into field "green status"
  370.     put EMPTY into field "blue status"
  371.     put EMPTY into field "hex status"
  372.     put EMPTY into field "paletteIndex status"
  373.   end if
  374. end
  375.  
  376. on mouseUpOutSide
  377.   if the rightMouseUp then
  378.     if sprite(146).pState = 1 then
  379.       nothing()
  380.     else
  381.       pSprite.cursor = currentCursor
  382.       put EMPTY into field "red status"
  383.       put EMPTY into field "green status"
  384.       put EMPTY into field "blue status"
  385.       put EMPTY into field "hex status"
  386.       put EMPTY into field "paletteIndex status"
  387.     end if
  388.   end if
  389. end
  390.  
  391. on mFlood me, aX, aY, aSourceColor
  392.   targetColor = myCurrentImage.getPixel(aX, aY)
  393.   myCurrentImage.setPixel(aX, aY, aSourceColor)
  394.   append(pPixelActorListX, aX)
  395.   append(pPixelActorListY, aY)
  396.   repeat while count(pPixelActorListX)
  397.     xCur = getAt(pPixelActorListX, 1)
  398.     yCur = getAt(pPixelActorListY, 1)
  399.     deleteAt(pPixelActorListX, 1)
  400.     deleteAt(pPixelActorListY, 1)
  401.     repeat with n = 1 to 4
  402.       xTest = xCur + getAt(pSpreadListX, n)
  403.       yTest = yCur + getAt(pSpreadListY, n)
  404.       if myCurrentImage.getPixel(xTest, yTest) = targetColor then
  405.         myCurrentImage.setPixel(xTest, yTest, aSourceColor)
  406.         append(pPixelActorListX, xTest)
  407.         append(pPixelActorListY, yTest)
  408.       end if
  409.     end repeat
  410.   end repeat
  411. end
  412.  
  413. on mFlood2 me, aX, aY, aSourceColor
  414.   targetColor = myCurrentImage.getPixel(aX, aY)
  415.   myCurrentImage.setPixel(aX, aY, aSourceColor)
  416.   append(pPixelActorListX, aX)
  417.   append(pPixelActorListY, aY)
  418.   repeat while count(pPixelActorListX)
  419.     xCur = getAt(pPixelActorListX, 1)
  420.     yCur = getAt(pPixelActorListY, 1)
  421.     deleteAt(pPixelActorListX, 1)
  422.     deleteAt(pPixelActorListY, 1)
  423.     repeat with n = 1 to 4
  424.       xTest = xCur + getAt(pSpreadListX, n)
  425.       yTest = yCur + getAt(pSpreadListY, n)
  426.       if myCurrentImage.getPixel(xTest, yTest) = targetColor then
  427.         if (((aX mod 2) = 1) and ((aY mod 2) = 0)) or (((aX mod 2) = 0) and ((aY mod 2) = 1)) then
  428.           if (((xTest mod 2) = 1) and ((yTest mod 2) = 0)) or (((xTest mod 2) = 0) and ((yTest mod 2) = 1)) then
  429.             myCurrentImage.setPixel(xTest, yTest, aSourceColor)
  430.             append(pPixelActorListX, xTest)
  431.             append(pPixelActorListY, yTest)
  432.           else
  433.             myCurrentImage.setPixel(xTest, yTest, targetColor)
  434.             append(pPixelActorListX, xTest)
  435.             append(pPixelActorListY, yTest)
  436.           end if
  437.           next repeat
  438.         end if
  439.         if (((xTest mod 2) = 1) and ((yTest mod 2) = 0)) or (((xTest mod 2) = 0) and ((yTest mod 2) = 1)) then
  440.           myCurrentImage.setPixel(xTest, yTest, targetColor)
  441.           append(pPixelActorListX, xTest)
  442.           append(pPixelActorListY, yTest)
  443.           next repeat
  444.         end if
  445.         myCurrentImage.setPixel(xTest, yTest, aSourceColor)
  446.         append(pPixelActorListX, xTest)
  447.         append(pPixelActorListY, yTest)
  448.       end if
  449.     end repeat
  450.   end repeat
  451. end
  452.